﻿using System;
using nRoute.Components;
using nRoute.Components.Composition;
using nRoute.Components.Routing;
using nRoute.Utilities;

namespace nRoute.Mapping
{
    public class DefaultNavigationContentLocator
		 : DefaultNavigationLocatorBase
    {
        private readonly Type _implementationType;

        public DefaultNavigationContentLocator(string url, Type implementationType)
		 : base(url)
        {
            Guard.ArgumentNotNull(implementationType, "implementationType");
            _implementationType = implementationType;
        }

#region Properties

        public Type ImplementationType
        {
            get { return _implementationType; }
        }

#endregion

#region Overrides

        protected override IRouteHandler CreateRouteHandler(ITypeBuilder typeBuilder)
        {
            return new NavigationContentHandler(typeBuilder, (t, p) => t.BuildType(_implementationType));
        }
        
#endregion

    }
}